#include "StdAfx.h"
#include "FloorSwitch.h"
#include "Player.h"
#include "EntityManager.h"

#define SWITCH_OFF (ENT_STATES[ IDLE ])
#define SWITCH_ON  (ENT_STATES[ WALKING ])


FloorSwitch::FloorSwitch(void)
{
    m_triggerer = NULL;
    m_flags |= EF_NOCOLLIDE;    // ents can walk over this
    m_flags |= EF_DRAWOVER;     // make sure this draws on the floor
}

FloorSwitch::~FloorSwitch(void)
{
}


/** Update the entity */
void FloorSwitch::Update( long dt)
{
    m_FSM.Update();
    
    IEntity* ent = GetActivator();
    if ( ent && !ent->GetBounds().Intersects( m_bounds ) )
    {
        SetState( SWITCH_OFF );
        m_triggerer = NULL;
    }
}

/** Collide with another entity */
bool FloorSwitch::CollideWith( IEntity* ent )
{
    SetState( SWITCH_ON );
    m_triggerer = ent;

    return false;
}